# 文件操作模块有以下功能(写在类里面的函数)：
# 读取文件内容
# 写入内容到文件中
# 复制文件
# 删除文件
# 文件改名
import os
class File:
    def read(self,filename):
        f=open(filename,'r',encoding='utf8')
        add =f.read()
        print(add)
    def whilt(self,filename):
        f =open(filename,'a',encoding='utf8')
        xie=f.write(filename)
        print('写入内容到文件')
    def cp(self,filename):
       fname,extend=os.path.splitext(filename)
       new_filename=fname+'副本'+extend
       f = open(new_filename, 'w', encoding='utf8')
       print('文件复制成功')
    def dele(self,filename):
        os.remove('new_filename')
        print('文件删除成功')
    def alter(self,filename):
        os.rename('filename','newfilename')
        print('修改文件成功')

p1 =File()
p1.read('demo.txt')
p1.whilt('demo.txt')
# p1.dele('demo-副本.txt')
# p1.cp('demo.txt')
# p1.alter('demo-副本.txt','demo1.txt')
